import { FishActionObject } from "./Obj/FishActionObject";
import { Obstacle } from "./Obj/Obstacle";
import { FishDirection } from "./defin/FishDirection";
import { ObstacleController } from "./ObjController/ObstacleController";
import { Speed } from "./defin/Speed";
import { Fish } from "./Obj/Fish";
import { UniformFishController } from "./ObjController/UniformFishController";
import { PowerForceFishController } from "./ObjController/PowerForceFishController";
import { FishModelDefin } from "./defin/FishModelDefin";
import { SWFPlayer } from "../../../scene/modle/SWFPlayer";
import { ObjectPool } from "../../../../../com/gengine/utils/pools/ObjectPool";
import { SkillsPlayer } from "../../../scene/player/item/SkillsPlayer";
import { ModelType } from "../../../scene/modle/data/ModelType";
import { FishPlayer } from "../../../scene/modle/FishPlayer";
import { LEFT } from "../../../../../FishDirection/LEFT";
type int = number;
//class FishFactory
    
    export  class FishFactory
    {
        

        public static randomObj(): FishActionObject
        {
            var loc1=Math.random();
            if (loc1 < 0.73) 
            {
                return FishFactory.randomFish();
            }
            return FishFactory.getObstacle();
        }

        public static getObstacle(): Obstacle
        {
            var loc1=Math.random();
            var loc2=loc1 < 0.6 ? FishDirection.RIGHT : LEFT;
            var loc3=new ObstacleController(Speed.SLOW, loc2);
            var loc4=new Obstacle(loc3, FishFactory.getFishPlayer("Obstacle.swf"));
            loc3.autoRun();
            return loc4;
        }

        public static randomFish(): Fish
        {
            var loc6=null;
            var loc1=Math.random();
            var loc2=Math.random();
            var loc3=Math.random();
            var loc4=FishFactory.randomFishModel();
            var loc5=loc3 < 0.6 ? FishDirection.RIGHT : LEFT;
            if (loc4.activeType == UniformFishController || loc4.activeType == null && loc1 < 0.7) 
            {
                if (loc2 < 0.6) 
                {
                    loc6 = FishFactory.getUniformFish(Speed.SLOW, loc5, loc4.url);
                }
                else if (loc2 < 0.88) 
                {
                    loc6 = FishFactory.getUniformFish(Speed.NORMAL, loc5, loc4.url);
                }
                else 
                {
                    loc6 = FishFactory.getUniformFish(Speed.FAST, loc5, loc4.url);
                }
            }
            else 
            {
                loc6 = FishFactory.getPowerForceFish(7, 0.05, 0.3, loc5, loc4.url);
            }
            loc6.maxDepth = loc4.maxDepth;
            loc6.minDepth = loc4.minDepth;
            return loc6;
        }

        public static getUniformFish(arg1: int, arg2: int=1, arg3: string=""): Fish
        {
            if (arg3 == "") 
            {
                arg3 = FishFactory.getRandomFishUrl();
            }
            var loc1=new UniformFishController(arg1, arg2);
            var loc2=FishFactory.getFishPlayer(arg3, arg2);
            var loc3=new Fish(loc1, loc2);
            loc1.autoRun();
            return loc3;
        }

        public static getPowerForceFish(arg1: number=3, arg2: number=0.05, arg3: number=0.1, arg4: int=1, arg5: string=""): Fish
        {
            if (arg5 == "") 
            {
                arg5 = FishFactory.getRandomFishUrl();
            }
            var loc1=new PowerForceFishController(arg1, arg2, arg3, arg4);
            var loc2=FishFactory.getFishPlayer(arg5, arg4);
            var loc3=new Fish(loc1, loc2);
            loc1.autoRun();
            return loc3;
        }

        public static randomFishModel(): FishModelDefin
        {
            var loc1=Math.floor(Math.random() * 8);
            return FishModelDefin.allFishType[loc1];
        }

        public static getSquibPlayer(): SWFPlayer
        {
            var loc1=ObjectPool.getObject(SkillsPlayer);
            loc1.load("FishSquib.swf", ModelType.Skill, null);
            return loc1;
        }

        /* internal  */static getFishPlayer(arg1: string, arg2: int=0): FishPlayer
        {
            var loc1=ObjectPool.getObject(FishPlayer);
            loc1.load(arg1, ModelType.Skill, null);
            if (arg2 != FishDirection.LEFT) 
            {
                loc1.isFishTurn = false;
            }
            else 
            {
                loc1.isFishTurn = true;
            }
            return loc1;
        }

        /* internal  */static getRandomFishUrl(): string
        {
            var loc1=Math.ceil(Math.random() * 8);
            if (loc1 == 0) 
            {
                loc1 = 1;
            }
            return "fish" + (loc1 + 1) + ".swf";
        }
    }
